﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using CanDoo.Core.Data;
using CanDoo.Data;
using CanDoo.Admin.Core.Models;

namespace CanDoo.Oil.Core.Models
{
    /// <summary>
    /// 立账类型
    /// </summary>
    [Description("立账类型")]
    public enum BuyBillTypeEnum
    { 
        /// <summary>
        /// 0手工立账
        /// </summary>
        [Display(Name = "手工立账")]
        ByHand,
        /// <summary>
        /// 1采购入库
        /// </summary>
        [Display(Name = "采购入库")]
        InStore,
        /// <summary>
        /// 2采购退货
        /// </summary>
        [Display(Name = "采购退货")]
        InBuyBack,
    }

    /// <summary>
    /// 结算状态
    /// </summary>
    [Description("结算状态")]
    public enum PayStateEnum
    {
        /// <summary>
        /// 0未结算
        /// </summary>
        [Display(Name = "未结算")]
        NoPayed,
        /// <summary>
        /// 1部分结算
        /// </summary>
        [Display(Name = "部分结算")]
        HalfPayed,
        /// <summary>
        /// 2全部结算
        /// </summary>
        [Display(Name = "全部结算")]
        AllPayed,
    }

    /// <summary>
    /// 实体类——应付账单
    /// </summary>
    [Serializable]
    [Description("应付账单")]
    public class BuyBill :  EntityBase,ICreatedTime, IAudited,IPassAutited,IRecyclable
    {
        /// <summary>
        ///账单编号
        /// </summary>
        [Display(Name = "账单编号")]
        [Required, StringLength(50)]
        public string Code { get; set; }

        /// <summary>
        ///供应商
        /// </summary>
        [Display(Name = "供应商")]
        public virtual Supplier Supplier { get; set; }
        /// <summary>
        ///供应商外键
        /// </summary>
        [Display(Name = "供应商外键")]
        public long SupplierId { get; set; }

        /// <summary>
        ///立账类型 0手工立账 1采购入库 2采购退货
        /// </summary>
        [Display(Name = "立账类型")]
        [Required]
        public BuyBillTypeEnum BuyBillType { get; set; }

        /// <summary>
        ///立账金额
        /// </summary>
        [Display(Name = "立账金额")]
        [Required]
        public double Money { get; set; }

        /// <summary>
        ///立账日期
        /// </summary>
        [Display(Name = "立账日期")]
        [Required]
        public DateTime? CreateDate { get; set; }

        /// <summary>
        ///已冲账金额
        /// </summary>
        [Display(Name = "已冲账金额")]
        [Required]
        public double PayedMoney { get; set; }

        /// <summary>
        ///未冲账金额
        /// </summary>
        [Display(Name = "未冲账金额")]
        [Required]
        public double WaitMoney { get; set; }

        /// <summary>
        ///账款到期日期
        /// </summary>
        [Display(Name = "账款到期日期")]
        [Required]
        public DateTime? NeedPayDate { get; set; }

        /// <summary>
        ///结算状态 0未结算 1部分结算 2全部结算
        /// </summary>
        [Display(Name = "结算状态")]
        [Required]
        public PayStateEnum PayState { get; set; }

        /// <summary>
        ///关联单据ID
        /// </summary>
        [Display(Name = "关联单据ID")]
        public long LinkEntityId { get; set; }

        /// <summary>
        ///入库单金额
        /// </summary>
        [Display(Name = "入库单金额")]
        public double LinkMoney { get; set; }

        /// <summary>
        ///入库单付现金额
        /// </summary>
        [Display(Name = "入库单付现金额")]
        public double LinkPayedMoney { get; set; }

        /// <summary>
        ///备注
        /// </summary>
        [Display(Name = "备注")]
        [StringLength(500)]
        public string Remark { get; set; }

        
        #region Implementation of ICreatedTime

        /// <summary>
        /// 获取设置 信息创建时间
        /// </summary>
        [Display(Name = "创建时间")]
        public DateTime CreatedTime { get; set; }
        #endregion

        #region Implementation of ICreatedAudited

        /// <summary>
        /// 获取或设置 创建者编号
        /// </summary>
        [Display(Name = "创建人")]
        public string CreatorUserId { get; set; }

        #endregion

        #region Implementation of IUpdateAutited

        /// <summary>
        /// 获取或设置 最后更新时间
        /// </summary>
        [Display(Name = "最后更新时间")]
        public DateTime? LastUpdatedTime { get; set; }

        /// <summary>
        /// 获取或设置 最后更新者编号
        /// </summary>
        [Display(Name = "最后更新用户")]
        public string LastUpdatorUserId { get; set; }

        #endregion
        #region IPassAutited 通过审核接口
        /// <summary>
        /// 审核状态
        /// </summary>
        [Display(Name = "审核状态")]
        public PassState PassState { get; set; }

        /// <summary>
        /// 审核用户
        /// </summary>
        [Display(Name = "审核用户")]
        public string PassAutitedUserId { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        [Display(Name="审核时间")]
        public DateTime? PassAutitedTime { get; set; }
        #endregion

        #region Implementation of IsDeleted 逻辑删除接口
        /// <summary>
        /// 逻辑删除接口
        /// </summary>
        [Display(Name = "是否删除")]
        public bool IsDeleted { get; set; }
        #endregion
    }
}
